package com.ruoyi.sys.garden.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.sys.garden.entity.TbService;
import com.ruoyi.sys.garden.service.ITbServiceService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 智能客服Controller
 * 
 * @author jinsuo
 * @date 2022-05-24
 */
@RestController
@RequestMapping("/system/service")
public class TbServiceController extends BaseController
{
    @Autowired
    private ITbServiceService tbServiceService;

    /**
     * 查询智能客服列表
     */
    @PreAuthorize("@ss.hasPermi('system:service:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbService tbService)
    {
        startPage();
        List<TbService> list = tbServiceService.selectTbServiceList(tbService);
        return getDataTable(list);
    }

    /**
     * 导出智能客服列表
     */
    @PreAuthorize("@ss.hasPermi('system:service:export')")
    @Log(title = "智能客服", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbService tbService)
    {
        List<TbService> list = tbServiceService.selectTbServiceList(tbService);
        ExcelUtil<TbService> util = new ExcelUtil<TbService>(TbService.class);
        util.exportExcel(response, list, "智能客服数据");
    }

    /**
     * 获取智能客服详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:service:query')")
    @GetMapping(value = "/{sId}")
    public AjaxResult getInfo(@PathVariable("sId") Long sId)
    {
        return AjaxResult.success(tbServiceService.selectTbServiceBySId(sId));
    }

    /**
     * 新增智能客服
     */
    @PreAuthorize("@ss.hasPermi('system:service:add')")
    @Log(title = "智能客服", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbService tbService)
    {
        return toAjax(tbServiceService.insertTbService(tbService));
    }

    /**
     * 修改智能客服
     */
    @PreAuthorize("@ss.hasPermi('system:service:edit')")
    @Log(title = "智能客服", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbService tbService)
    {
        return toAjax(tbServiceService.updateTbService(tbService));
    }

    /**
     * 删除智能客服
     */
    @PreAuthorize("@ss.hasPermi('system:service:remove')")
    @Log(title = "智能客服", businessType = BusinessType.DELETE)
	@DeleteMapping("/{sIds}")
    public AjaxResult remove(@PathVariable Long[] sIds)
    {
        return toAjax(tbServiceService.deleteTbServiceBySIds(sIds));
    }
}
